<?php
class o2o_ctl_admin_order extends desktop_controller
{
    /**
     * 查询o2o订单对应的发货单状态
     */
    function get_delivery_status()
    {
        $order_bn    = $_POST['order_bn'];
        if(empty($order_bn))
        {
            $result    = array('status'=>'fail', 'msg'=>'参数为空!');
            echo json_encode($result);
            exit;
        }
        
        $wapDlyObj    = app::get('wap')->model('delivery');
        $dataList     = $wapDlyObj->getList('delivery_id, status, confirm, order_bn', array('order_bn'=>$order_bn));
        if($dataList)
        {
            foreach ($dataList as $key => $val)
            {
                if($val['status']=='3' && $val['confirm']='1')
                {
                    $val['status']    = '已核销';
                }
                elseif($val['status']=='1' && $val['confirm']='3')
                {
                    $val['status']    = '取消订单';
                }
                elseif($val['confirm']=='1')
                {
                    $val['status']    = '已确认';
                }
                elseif($val['confirm']=='2')
                {
                    $val['status']    = '已拒绝';
                }
                else
                {
                    $val['status']    = '待确认';
                }
                
                $items[]    = array('order_bn'=>$val['order_bn'], 'status' =>$val['status']);
            }
        }
        
        $result    = array('status'=>'succ', 'data'=>$items);
        
        echo json_encode($result);
        exit;
    }
}